<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>上传宝宝头像</title>
    <link rel="stylesheet" href="/static/weui-1.0.2/dist/style/weui.css"/>
    <link rel="stylesheet" href="/static/weui-1.0.2/dist/example/example.css"/>
    <script src="/static/admin/css/jquery-3.0.0.min.js"></script>
</head>
<style>
    .you{
        margin-left:17px;
    }
</style>
<body>

<div class="page__hd" style="margin: 0 auto;">
    <h1 class="page__title" style="text-align: center;">上传宝宝头像</h1>
</div>
<div class="page__bd">


    <div class="weui-cells weui-cells_form">
        <div class="weui-cell">
            <div class="weui-cell__bd">
                <div class="weui-uploader">

                    <div class="weui-uploader__bd">
                        <ul class="weui-uploader__files" id="uploaderFiles">

                        </ul>
                        <div class="weui-uploader__input-box">
                            <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="weui-btn-area">
        <a class="weui-btn weui-btn_primary" href="javascript:" style="width:70%" id="showTooltips">跳过</a>
    </div>
</div>

<script type="text/javascript">
    $(function(){
        var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
            $gallery = $("#gallery"), $galleryImg = $("#galleryImg"),
            $uploaderInput = $("#uploaderInput"),
            $uploaderFiles = $("#uploaderFiles")
        ;

        $uploaderInput.on("change", function(e){
            var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
            for (var i = 0, len = files.length; i < len; ++i) {
                var file = files[i];

                if (url) {
                    src = url.createObjectURL(file);
                } else {
                    src = e.target.result;
                }
                alert(src);
                $uploaderFiles.append($(tmpl.replace('#url#', src)));
            }
        });
        $uploaderFiles.on("click", "li", function(){
            $galleryImg.attr("style", this.getAttribute("style"));
            $gallery.fadeIn(100);
        });
        $gallery.on("click", function(){
            $gallery.fadeOut(100);
        });
    });

    $('#showTooltips').click(function () {
        location.href = "{:url('user')}";
        return;
    })
</script>


</body>
</html>